package org.otherworld.frame.filebrowser.action;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;

import javax.swing.JPanel;
import javax.swing.JTree;
import javax.swing.tree.TreePath;

import org.otherworld.frame.filebrowser.tree.FileTreeNode;
import org.otherworld.frame.textwriter.TextWriter;

public class FileBrowserEdit implements ActionListener{
	private JPanel panel;
	private JTree tree;
	private File[] editPath;

	public FileBrowserEdit(JPanel panel, JTree tree) {
		this.panel = panel;
		this.tree = tree;
	}
	@Override
	public void actionPerformed(ActionEvent e) {
		JTree tree = this.tree;
		TreePath path = tree.getSelectionPath();
		File file = ((FileTreeNode)path.getLastPathComponent()).getFile();
		try {
			new TextWriter(file, "edit");
		} catch (Exception ex) {
			ex.printStackTrace();
		}
	}

}
